<?php

/**
 * article actions.
 *
 * @package    anchor
 * @subpackage article
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class articleActions extends myActions
{
  public function executeIndex(sfWebRequest $request)
  {
    // Define acceptable filters
    $filters 							= array ();
    $filters["new"] 			= "newActiveArticles";
    $filters["top"] 			= "topActiveArticles";
		$filters["law"] 			= "lawActiveArticles";
    $filters["normative"] = "normativeActiveArticles";            
    // Get filter value
    $filter = $request->getParameter('filter', null);
		// Check for needed filter
		if(is_null($filter) or !array_key_exists($filter, $filters))
			$this->redirect("@articlefilter?module=article&action=index&filter=new&page=");    

		// Display grid
    $this->pager = new sfDoctrinePager('article', sfConfig::get('app_article_list_count'));
		$this->pager->setTableMethod($filters[$filter]);			
    $this->pager->setPage($request->getParameter('page', 1));
    $this->pager->init();  	
  }
  /**
   * Method to display calculation example
   * @param sfWebRequest $request
   */
  public function executeShow(sfWebRequest $request)
  {
    $this->article = Doctrine::getTable("article")->getArticleExample($request->getParameter('id', null));
  }
	/**
	 * Method to display articles content
	 * @param sfWebRequest $request
	 */
	public function executeContent(sfWebRequest $request)
	{
    $this->articles = Doctrine::getTable("article")->createQuery()->execute();
		
	}
}
